package com.honey.mybatis.generator;

import org.java.plugin.Plugin;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.compilation.java.Field;
import com.honey.compilation.java.InnerClass;
import com.honey.compilation.java.InnerEnum;
import com.honey.compilation.java.Method;
import com.honey.compilation.java.StaticBlock;
import com.honey.core.compiler.CompilationException;
import com.honey.core.compiler.ContentType;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.generator.java.extension.point.GeneratorJavaClass;

public class MybatisBaseDaoImplementsExtension  extends AbstractMybatisExtension  implements  GeneratorJavaClass{
	
	private AbstractProduceJavaCompilation abstractProduceJavaCompilation;
	
	private AbstractJavaCompilation abstractJavaCompilation = null;
	
	public MybatisBaseDaoImplementsExtension(Plugin belongPlugin) {
		super(belongPlugin);
	}
	
	@Override
	public AbstractJavaCompilation createNewCompilation(
		IntrospectSchema introspectSchema, IntrospectSchemaColumn introspectSchemaColumn) {
		try {
			abstractProduceJavaCompilation = MybatisFactory.getAbstractProduceJavaCompilation(MybatisFactory.MybatisClass.BASE_DAO_IMPLEMENTS, mybatisPlugin, introspectSchema, introspectSchemaColumn);			
			abstractJavaCompilation = abstractProduceJavaCompilation.produceCompilation();
			
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		return abstractJavaCompilation ;
	}
	
	@Override
	public FullyQualifiedJavaType getType() {
		return abstractJavaCompilation.getType();
	}
	
	@Override
	public Method[] importMethods() {
		Method[] answer = null;
		try {
			answer = abstractProduceJavaCompilation.produceMethods();
			
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		return  answer ;
	}

	@Override
	public Field[] importFields() {
		Field[] answer = null;
		try {
			answer = abstractProduceJavaCompilation.produceFields();
			
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		return  answer ;
	}

	@Override
	public StaticBlock[] importStaticBlocks() {
		return null;
	}

	@Override
	public InnerClass[] importInnerClass() {
		return null;
	}

	@Override
	public InnerEnum[] importInnerEnumClass() {
		return null;
	}

	@Override
	public FullyQualifiedJavaType[] importImportClass() {
		FullyQualifiedJavaType[] answer = null;
		try {
			answer = abstractProduceJavaCompilation.produceImportClass();
			
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		return  answer ;
	}
	
	/* (non-Javadoc)
	 * @see com.honey.generator.java.extension.point.GeneratorJavaClass#getContentType()
	 */
	@Override
	public ContentType getContentType() {
		
		return ContentType.JAVA_BASE_DAO;
	}
	
	@Override
	public void clean() {
		
	}

}
